package com.junzhiit.nengji.shop.model.enums;

import com.bainaeco.framework.exception.InvalidArgumentException;

public enum GoodsSearchStatus {
	
	ALL(0,"所有"),
	RECOMMEND(1,"推荐"),
	PRICEDESC(2,"价格降序"),
	PRICEASC(3,"价格升序"),
	DISCOUNT(4,"折扣"),
	ISSHOP(5,"是否到店"),
	ISMAIL(6,"是否直邮"),
	ISDISTRIBUTION(7,"是否配送"),
	SALES_VOLUME(8,"销量"),
	NEW_TIME(9,"最新时间"),
	ISEAT(10,"是否堂食"),
	ISRESERVE(11,"是否预定");
	
	private Integer status;
	
	private String value;

	private GoodsSearchStatus(Integer status,String value){
		this.status = status;
		this.value = value;
	}

	public int toIntStatus() {
		return this.status;
	}
	
	public String toStringValue() {
		return this.value;
	}

	public static GoodsSearchStatus toFlag(int status) {
		if (ALL.status == status) {
			return ALL;
		} else if (RECOMMEND.status == status) {
			return RECOMMEND;
		} else if (PRICEDESC.status == status) {
			return PRICEDESC;
		} else if (PRICEASC.status == status) {
			return PRICEASC;
		} else if (DISCOUNT.status == status) {
			return DISCOUNT;
		}else if (SALES_VOLUME.status == status) {
			return SALES_VOLUME;
		}else if (NEW_TIME.status == status) {
			return NEW_TIME;
		}else if (ISEAT.status == status) {
			return ISEAT;
		}else if (ISRESERVE.status == status) {
			return ISRESERVE;
		} else {
			throw new InvalidArgumentException("Unknown status[" + status + "].");
		}
	}
}
